home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
17 Bit Software 5: The Fifth Dimension
/
17 Bit - The Fifth Dimension (1995)(17 Bit Software)[!].iso
/
files
/
3728.dms
/
3728.adf
/
XPKDisk
/
prefswindow.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-12-29
|
8KB
|
259 lines
/*
* Source machine generated by GadToolsBox V2.0b
* which is (c) Copyright 1991-1993 Jaba Development
*
* GUI Designed by : Olaf 'Rhialto' Seibert
*/
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/imageclass.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/utility_protos.h>
#include <string.h>
#include "prefswindow.h"
extern void *SysBase;
extern void *GfxBase;
struct Screen *Scr = NULL;
UBYTE *PubScreenName = NULL;
APTR VisualInfo = NULL;
struct Window *PrefsWnd = NULL;
struct Gadget *PrefsGList = NULL;
struct Menu *PrefsMenus = NULL;
UWORD PrefsZoom[4];
struct Gadget *PrefsGadgets[10];
UWORD PrefsLeft = 55;
UWORD PrefsTop = 18;
UWORD PrefsWidth = 349;
UWORD PrefsHeight = 141;
UBYTE *PrefsWdt = (UBYTE *)"xpkdisk.device Prefs";
struct TextAttr *Font, Attr;
UWORD FontX, FontY;
UWORD OffX, OffY;
struct NewMenu PrefsNewMenu[] = {
NM_TITLE, (STRPTR)"Project", NULL, 0, NULL, NULL,
NM_ITEM, (STRPTR)"About", NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Open...", (STRPTR)"O", 0, 0L, NULL,
NM_ITEM, (STRPTR)"Save", (STRPTR)"S", 0, 0L, NULL,
NM_ITEM, (STRPTR)"Save As...", (STRPTR)"A", 0, 0L, NULL,
NM_ITEM, (STRPTR)"Use", (STRPTR)"U", 0, 0L, NULL,
NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Quit", (STRPTR)"Q", 0, 0L, NULL,
NM_TITLE, (STRPTR)"Edit", NULL, 0, NULL, NULL,
NM_ITEM, (STRPTR)"Reset To Defaults", (STRPTR)"D", 0, 0L, NULL,
NM_ITEM, (STRPTR)"Last Saved", (STRPTR)"L", 0, 0L, NULL,
NM_ITEM, (STRPTR)"Restore", (STRPTR)"R", 0, 0L, NULL,
NM_END, NULL, NULL, 0, 0L, NULL };
UWORD PrefsGTypes[] = {
SLIDER_KIND,
SLIDER_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
SLIDER_KIND,
STRING_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND
};
struct NewGadget PrefsNGad[] = {
95, 103, 158, 11, (UBYTE *)"Unit", NULL, GD_UNIT, PLACETEXT_LEFT, NULL, NULL,
110, 82, 158, 11, (UBYTE *)"Cache size", NULL, GD_MAXCACHE, PLACETEXT_LEFT, NULL, NULL,
242, 52, 26, 11, (UBYTE *)"CMD_UPDATE required", NULL, GD_CMDUPDATE, PLACETEXT_LEFT, NULL, NULL,
242, 22, 26, 11, (UBYTE *)"Timeout required", NULL, GD_DELAY, PLACETEXT_LEFT, NULL, NULL,
242, 67, 26, 11, (UBYTE *)"Safe write", NULL, GD_SAFE, PLACETEXT_LEFT, NULL, NULL,
110, 37, 158, 11, (UBYTE *)"Time", NULL, GD_TIME, PLACETEXT_LEFT, NULL, NULL,
171, 6, 97, 12, (UBYTE *)"Compression", NULL, GD_METHOD, PLACETEXT_LEFT, NULL, NULL,
14, 120, 95, 16, (UBYTE *)"Save", NULL, GD_SAVE, PLACETEXT_IN, NULL, NULL,
127, 120, 95, 16, (UBYTE *)"Use", NULL, GD_USE, PLACETEXT_IN, NULL, NULL,
241, 120, 95, 16, (UBYTE *)"Quit", NULL, GD_QUIT, PLACETEXT_IN, NULL, NULL
};
ULONG PrefsGTags[] = {
(GTSL_Max), 7, (GTSL_MaxLevelLen), 3, (GTSL_LevelFormat), (ULONG)"%ld", (GTSL_LevelPlace), (PLACETEXT_RIGHT), (PGA_Freedom), LORIENT_HORIZ, (GA_RelVerify), TRUE, (TAG_DONE),
(GTSL_Max), 64, (GTSL_Level), 8, (GTSL_MaxLevelLen), 4, (GTSL_LevelFormat), (ULONG)"%2ld", (GTSL_LevelPlace), (PLACETEXT_RIGHT), (PGA_Freedom), LORIENT_HORIZ, (GA_RelVerify), TRUE, (TAG_DONE),
(GTCB_Checked), TRUE, (TAG_DONE),
(GTCB_Checked), TRUE, (TAG_DONE),
(TAG_DONE),
(GTSL_Max), 300, (GTSL_Level), 5, (GTSL_MaxLevelLen), 6, (GTSL_LevelFormat), (ULONG)"%3ld s", (GTSL_LevelPlace), (PLACETEXT_RIGHT), (PGA_Freedom), LORIENT_HORIZ, (GA_RelVerify), TRUE, (TAG_DONE),
(GA_TabCycle), FALSE, (GTST_String), (ULONG)"BLZW.100", (GTST_MaxChars), 8, (STRINGA_Justification), (GACT_STRINGCENTER), (TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE)
};
static UWORD ComputeX( UWORD value )
{
return(( UWORD )((( FontX * value ) + 4 ) / 8 ));
}
static UWORD ComputeY( UWORD value )
{
return(( UWORD )((( FontY * value ) + 4 ) / 8 ));
}
static void ComputeFont( UWORD width, UWORD height )
{
Font = &Attr;
Font->ta_Name = (STRPTR)Scr->RastPort.Font->tf_Message.mn_Node.ln_Name;
Font->ta_YSize = FontY = Scr->RastPort.Font->tf_YSize;
FontX = Scr->RastPort.Font->tf_XSize;
OffX = Scr->WBorLeft;
OffY = Scr->RastPort.TxHeight + Scr->WBorTop + 1;
if ( width && height ) {
if (( ComputeX( width ) + OffX + Scr->WBorRight ) > Scr->Width )
goto UseTopaz;
if (( ComputeY( height ) + OffY + Scr->WBorBottom ) > Scr->Height )
goto UseTopaz;
}
return;
UseTopaz:
Font->ta_Name = (STRPTR)"topaz.font";
FontX = FontY = Font->ta_YSize = 8;
}
int SetupScreen( void )
{
if ( ! ( Scr = LockPubScreen( PubScreenName )))
return( 1L );
ComputeFont( 0, 0 );
if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
return( 2L );
return( 0L );
}
void CloseDownScreen( void )
{
if ( VisualInfo ) {
FreeVisualInfo( VisualInfo );
VisualInfo = NULL;
}
if ( Scr ) {
UnlockPubScreen( NULL, Scr );
Scr = NULL;
}
}
void PrefsRender( void )
{
ComputeFont( PrefsWidth, PrefsHeight );
DrawBevelBox( PrefsWnd->RPort, OffX + ComputeX( 14 ),
OffY + ComputeY( 3 ),
ComputeX( 322 ),
ComputeY( 95 ),
GT_VisualInfo, VisualInfo, TAG_DONE );
}
int OpenPrefsWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD wleft = PrefsLeft, wtop = PrefsTop, ww, wh;
ComputeFont( PrefsWidth, PrefsHeight );
ww = ComputeX( PrefsWidth );
wh = ComputeY( PrefsHeight );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( g = CreateContext( &PrefsGList )))
return( 1L );
for( lc = 0, tc = 0; lc < Prefs_CNT; lc++ ) {
CopyMem((char * )&PrefsNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = Font;
ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
ng.ng_Width = ComputeX( ng.ng_Width );
ng.ng_Height = ComputeY( ng.ng_Height);
PrefsGadgets[ lc ] = g = CreateGadgetA((ULONG)PrefsGTypes[ lc ], g, &ng, ( struct TagItem * )&PrefsGTags[ tc ] );
while( PrefsGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
if ( ! ( PrefsMenus = CreateMenus( PrefsNewMenu, GTMN_FrontPen, 0L, TAG_DONE )))
return( 3L );
LayoutMenus( PrefsMenus, VisualInfo, TAG_DONE );
PrefsZoom[0] = PrefsLeft;
PrefsZoom[1] = PrefsTop;
if ( PrefsWdt )
PrefsZoom[2] = TextLength( &Scr->RastPort, (UBYTE *)PrefsWdt, strlen((char *)PrefsWdt )) + 80;
else
PrefsZoom[2] = 80L;
PrefsZoom[3] = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
if ( ! ( PrefsWnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, SLIDERIDCMP|CHECKBOXIDCMP|STRINGIDCMP|BUTTONIDCMP|IDCMP_MENUPICK|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_SIMPLE_REFRESH,
WA_Gadgets, PrefsGList,
WA_Title, PrefsWdt,
WA_ScreenTitle, "xpkdisk.device Prefs",
WA_PubScreen, Scr,
WA_Zoom, PrefsZoom,
TAG_DONE )))
return( 4L );
SetMenuStrip( PrefsWnd, PrefsMenus );
GT_RefreshWindow( PrefsWnd, NULL );
PrefsRender();
return( 0L );
}
void ClosePrefsWindow( void )
{
if ( PrefsMenus ) {
ClearMenuStrip( PrefsWnd );
FreeMenus( PrefsMenus );
PrefsMenus = NULL; }
if ( PrefsWnd ) {
CloseWindow( PrefsWnd );
PrefsWnd = NULL;
}
if ( PrefsGList ) {
FreeGadgets( PrefsGList );
PrefsGList = NULL;
}
}